package com.aps.server.controller;

import com.aps.common.entity.Result;
import com.aps.server.entity.ApsOrder;
import com.aps.server.service.ApsOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * APS订单控制器
 * 提供订单相关的REST API接口
 */
@Slf4j
@RestController
@RequestMapping("/api/aps-orders")
@RequiredArgsConstructor
@Tag(name = "APS订单管理", description = "APS订单相关的API接口")
public class ApsOrderController {
    @Resource
     ApsOrderService apsOrderService;

    /**
     * 查询待排程订单列表
     * @return 待排程订单列表
     */
    @GetMapping("unselected")
    @Operation(summary = "查询待排程订单", description = "获取所有待排程的订单列表")
    public Result<List<ApsOrder>> getUnselectedOrders() {
        Result<List<ApsOrder>> result = new Result<>();
        List<ApsOrder> list = apsOrderService.getUnselectedOrders();
        result.setData(list);
        return result;
    }

    /**
     *选择 订单
     * @param apsOrder
     * @return
     */
    @PostMapping("select-orders")
    @Operation(summary = "选择订单", description = "将选中的订单标记为已选择并保存")
    public Result<List<ApsOrder>> selectedOrder(@RequestBody List<ApsOrder> apsOrder) {
        Result<List<ApsOrder>> result = new Result<>();
        List<ApsOrder> list = apsOrderService.selectedOrder(apsOrder);
        result.setData(list);
        return result;
    }


//    /**
//     * 订单校验
//     */
//    @PostMapping
//    public Result<ApsOrder> addOrder(@RequestBody ApsOrder order) {
//        Result<ApsOrder> result = new Result<>();
//        ApsOrder list = apsOrderService.orderCheck(order);
//        result.setData(list);
//        return result;
//    }
}
